package com.superc.lib.helper;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;

public class NetworkHelper {

	public static ArrayList<InetAddress> getLocalAddress(){
		Enumeration<NetworkInterface> interfaces;
		ArrayList<InetAddress> results=new ArrayList<InetAddress>();
		try {
			interfaces = NetworkInterface.getNetworkInterfaces();
			while(interfaces.hasMoreElements()){
				NetworkInterface networkInterface = interfaces.nextElement();
				Enumeration<InetAddress>  addresses=networkInterface.getInetAddresses();
				while(addresses.hasMoreElements()){
					InetAddress address=addresses.nextElement();
					results.add(address);
				}
			}
		} catch (SocketException e) {
			e.printStackTrace();
		}
		return results;
		
	}
	
}
